package com.myserver.myserver;

import com.netflix.appinfo.InstanceInfo;
import org.springframework.cloud.netflix.eureka.server.event.*;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class EurekaListener {

    //下线
    @EventListener
    public void listen(EurekaInstanceCanceledEvent e){
        String appName = e.getAppName();
        String id = e.getServerId();
        System.out.println("cancel "+appName+" "+id);
    }

    //注册
    @EventListener
    public void listen(EurekaInstanceRegisteredEvent e){
        InstanceInfo i = e.getInstanceInfo();
        System.out.println("regist "+i);
    }

    //续约
    @EventListener
    public void listen(EurekaInstanceRenewedEvent e){
        String name = e.getAppName();
        System.out.println("renew "+name);
    }


    //续约
    @EventListener
    public void listen(EurekaRegistryAvailableEvent e){
        System.out.println("e start ");
    }

    //启动
    @EventListener
    public void listen(EurekaServerStartedEvent e){
        System.out.println("e server start ");
    }
}
